<template>
    <el-select v-model="sval"  :placeholder="placeholder" @change="getData" style="width:100%">
        <el-option v-for="dt in lists" :key="dt[valuekey]" :label="dt[label]" :value="dt[valuekey]" @click.native="item=dt"></el-option>
    </el-select>
</template>

<script>
// 艺术家选择器
import { categoryAll} from '@/api/chain'
export default {
    props:['value','placeholder','valuekey','label'],
    data(){
        return{
            lists:[],
            sval:'',
            item:''
        }
    },
    created(){
        this.sval = this.value
        categoryAll().then(res => {
            if (res.success) {
                this.lists = res.data
            }
        })
    },
    watch:{
        value(n,o){
            this.sval = n
        }
    },
    methods:{
        getData(val){
            this.$emit('input',val)
        },
        getKeyValue(key){  // 给外部调用
            console.log("this.item",this.item)
            if(key){
                return this.item[key]
            }else{
               this.item 
            }
        }
    }
}
</script>

<style>

</style>